package com.example.asus.practice;

import android.media.MediaPlayer;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.AppCompatButton;
import android.view.View;

public class PlayMusic extends AppCompatActivity {
    AppCompatButton bt_play;
    AppCompatButton bt_pause;
    AppCompatButton bt_stop;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_play_music);
        final MediaPlayer mediaPlayer = MediaPlayer.create(this,R.raw.hush);

        bt_play = (AppCompatButton)findViewById(R.id.bt_play);
        bt_pause = (AppCompatButton)findViewById(R.id.bt_pause);
        bt_stop = (AppCompatButton)findViewById(R.id.bt_stop);

        bt_play.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mediaPlayer.start();
            }
        });
        bt_pause.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mediaPlayer.pause();
            }
        });
        bt_stop.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mediaPlayer.stop();
            }
        });



    }
}
